package com.fatgirl.utils
{
	import flash.net.LocalConnection;
	import flash.system.System;
	
	/**
	 *  
	 * 强制GC类
	 * @author iceman
	 * 
	 */
	public class GC
	{
		private static var s_offOn:Boolean;
		public function GC()
		{
		}
		/**
		 * 强制GC开关 
		 * @param _b
		 * 
		 */
		public static function offOn(_b:Boolean):void
		{
			s_offOn = _b;
			ftrace(GC,"设置GC开关:"+s_offOn);
		}
		public static function clear():void
		{
			if(!s_offOn)
			{
				return;
			}
			ftrace(GC,"System.totalMemory1="+System.totalMemory);
			try
		    {
		     var lc1:LocalConnection= new LocalConnection();
		     var lc2:LocalConnection = new LocalConnection();
		     lc1.connect("gcConnection");
		     lc2.connect("gcConnection");
		    }
		    catch (e:Error)
		    {
				System.gc();
				System.gc();
		    }
			ftrace(GC,"System.totalMemory2="+System.totalMemory);
		}

	}
}